/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import DAO.ValidarRutDAO;
import DTO.usuarioDTO;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;
//import sun.security.jca.JCAUtil;

/**
 *
 * @author User
 */
public class ModuloAdmiModificarUsuario extends javax.swing.JFrame {

    usuarioDTO user;

    public ModuloAdmiModificarUsuario(usuarioDTO user) {
        initComponents();
        this.user = user;
        this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);

    }
    String clave;

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        pnlIngreseRutGarante = new javax.swing.JPanel();
        lblRut = new javax.swing.JLabel();
        txtRutBuscarModificaUsuario = new javax.swing.JTextField();
        btnBuscarModusuario = new javax.swing.JButton();
        pnlIngresarDatosGarante = new javax.swing.JPanel();
        pnlDatosPersonales = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtApellPatModiusuario = new javax.swing.JTextField();
        txtApellMatModUsuario = new javax.swing.JTextField();
        txtRutAdmiModUsuario = new javax.swing.JTextField();
        txtNombreModUsuar = new javax.swing.JTextField();
        rdMascAdmiModUsuario = new javax.swing.JRadioButton();
        rdFemModUsuario = new javax.swing.JRadioButton();
        jcFecha_Nacimiento = new com.toedter.calendar.JDateChooser();
        pnlNumContacto = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        txtTelPartModUsuar = new javax.swing.JTextField();
        txtTrabModUsuario = new javax.swing.JTextField();
        txtMovModUsuario = new javax.swing.JTextField();
        txtFaxModUsuario = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        txtMailModUsuario = new javax.swing.JTextField();
        pnlDireParticular = new javax.swing.JPanel();
        txtPassModUsuar = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        cmbPerfilUsuario = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        txtUsuarioModUsuario = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        chkEstadoUsuario = new javax.swing.JCheckBox();
        btnModUsuario = new javax.swing.JButton();
        btnAdmiModificarUsuario = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGE/logo.JPG"))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 18)); // NOI18N
        jLabel1.setText("MODIFICACIÓN DE USUARIO");

        pnlIngreseRutGarante.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INGRESE RUT USUARIO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        lblRut.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        lblRut.setText("RUT");

        btnBuscarModusuario.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnBuscarModusuario.setText("BUSCAR");
        btnBuscarModusuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarModusuarioActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlIngreseRutGaranteLayout = new javax.swing.GroupLayout(pnlIngreseRutGarante);
        pnlIngreseRutGarante.setLayout(pnlIngreseRutGaranteLayout);
        pnlIngreseRutGaranteLayout.setHorizontalGroup(
            pnlIngreseRutGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIngreseRutGaranteLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblRut)
                .addGap(18, 18, 18)
                .addGroup(pnlIngreseRutGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtRutBuscarModificaUsuario)
                    .addComponent(btnBuscarModusuario, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE))
                .addContainerGap(52, Short.MAX_VALUE))
        );
        pnlIngreseRutGaranteLayout.setVerticalGroup(
            pnlIngreseRutGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlIngreseRutGaranteLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnlIngreseRutGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblRut)
                    .addComponent(txtRutBuscarModificaUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBuscarModusuario)
                .addContainerGap())
        );

        pnlIngresarDatosGarante.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INGRESAR DATOS ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 12), java.awt.Color.blue)); // NOI18N

        pnlDatosPersonales.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS PERSONALES", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel3.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel3.setText("RUT");

        jLabel4.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel4.setText("APELLIDO PATERNO");

        jLabel5.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel5.setText("APELLIDO MATERNO");

        jLabel6.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel6.setText("NOMBRE");

        jLabel7.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel7.setText("FECHA NACIMIENTO");

        jLabel8.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel8.setText("SEXO");

        txtRutAdmiModUsuario.setBackground(new java.awt.Color(255, 255, 102));
        txtRutAdmiModUsuario.setDisabledTextColor(new java.awt.Color(0, 0, 204));

        buttonGroup1.add(rdMascAdmiModUsuario);
        rdMascAdmiModUsuario.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        rdMascAdmiModUsuario.setSelected(true);
        rdMascAdmiModUsuario.setText("MASCULINO");

        buttonGroup1.add(rdFemModUsuario);
        rdFemModUsuario.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        rdFemModUsuario.setText("FEMENINO");

        javax.swing.GroupLayout pnlDatosPersonalesLayout = new javax.swing.GroupLayout(pnlDatosPersonales);
        pnlDatosPersonales.setLayout(pnlDatosPersonalesLayout);
        pnlDatosPersonalesLayout.setHorizontalGroup(
            pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                        .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8))
                        .addGap(28, 28, 28)
                        .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(txtNombreModUsuar, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(txtApellMatModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jcFecha_Nacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                                .addComponent(rdMascAdmiModUsuario)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rdFemModUsuario))))
                    .addComponent(jLabel7)
                    .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                        .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3))
                        .addGap(32, 32, 32)
                        .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtRutAdmiModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtApellPatModiusuario, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlDatosPersonalesLayout.setVerticalGroup(
            pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtRutAdmiModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtApellPatModiusuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtApellMatModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombreModUsuar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jcFecha_Nacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdMascAdmiModUsuario)
                    .addComponent(rdFemModUsuario)
                    .addComponent(jLabel8))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlNumContacto.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "CONTACTO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel14.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel14.setText("TEL. PARTICULAR");

        jLabel15.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel15.setText("TEL. TRABAJO ");

        jLabel16.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel16.setText("TEL. MOVIL");

        jLabel17.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel17.setText("FAX");

        jLabel26.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel26.setText("MAIL");

        javax.swing.GroupLayout pnlNumContactoLayout = new javax.swing.GroupLayout(pnlNumContacto);
        pnlNumContacto.setLayout(pnlNumContactoLayout);
        pnlNumContactoLayout.setHorizontalGroup(
            pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlNumContactoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15)
                    .addComponent(jLabel16)
                    .addComponent(jLabel17)
                    .addComponent(jLabel26))
                .addGap(18, 18, 18)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtFaxModUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(txtMovModUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(txtTrabModUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(txtTelPartModUsuar, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(txtMailModUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE))
                .addContainerGap(98, Short.MAX_VALUE))
        );
        pnlNumContactoLayout.setVerticalGroup(
            pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlNumContactoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(txtTelPartModUsuar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTrabModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtMovModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtFaxModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(txtMailModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlDireParticular.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OTROS DATOS", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel10.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel10.setText("PASSWORD");

        jLabel9.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel9.setText("ESTADO DE USUARIO");

        cmbPerfilUsuario.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        cmbPerfilUsuario.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Gerente", "Jefe Sucursal", "Supervisor", "Ejecutivo" }));

        jLabel11.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel11.setText("USUARIO");

        jLabel13.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel13.setText("TIPO DE USUARIO");

        chkEstadoUsuario.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        chkEstadoUsuario.setText("ACTIVO");

        javax.swing.GroupLayout pnlDireParticularLayout = new javax.swing.GroupLayout(pnlDireParticular);
        pnlDireParticular.setLayout(pnlDireParticularLayout);
        pnlDireParticularLayout.setHorizontalGroup(
            pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlDireParticularLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13)
                    .addComponent(jLabel9))
                .addGap(21, 21, 21)
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chkEstadoUsuario)
                    .addComponent(cmbPerfilUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(69, 69, 69)
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlDireParticularLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(60, 60, 60)
                        .addComponent(txtUsuarioModUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE))
                    .addGroup(pnlDireParticularLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(txtPassModUsuar, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(20, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        pnlDireParticularLayout.setVerticalGroup(
            pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDireParticularLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtUsuarioModUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addComponent(chkEstadoUsuario))
                .addGap(18, 18, 18)
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPassModUsuar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel13)
                    .addComponent(cmbPerfilUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(47, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pnlIngresarDatosGaranteLayout = new javax.swing.GroupLayout(pnlIngresarDatosGarante);
        pnlIngresarDatosGarante.setLayout(pnlIngresarDatosGaranteLayout);
        pnlIngresarDatosGaranteLayout.setHorizontalGroup(
            pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIngresarDatosGaranteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlIngresarDatosGaranteLayout.createSequentialGroup()
                        .addComponent(pnlDatosPersonales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pnlNumContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(pnlDireParticular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlIngresarDatosGaranteLayout.setVerticalGroup(
            pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIngresarDatosGaranteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlDatosPersonales, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlNumContacto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlDireParticular, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        btnModUsuario.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnModUsuario.setText("MODIFICAR");
        btnModUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModUsuarioActionPerformed(evt);
            }
        });

        btnAdmiModificarUsuario.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnAdmiModificarUsuario.setText("VOLVER AL MENU");
        btnAdmiModificarUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdmiModificarUsuarioActionPerformed(evt);
            }
        });

        jLabel12.setText("MENÚ ADMINISTRADOR\\MODIFICACIÓN DE USUARIO");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addGap(18, 18, 18)
                                .addComponent(pnlIngreseRutGarante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(133, 133, 133)
                                .addComponent(jLabel1))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(pnlIngresarDatosGarante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(165, 165, 165)
                        .addComponent(btnModUsuario)
                        .addGap(109, 109, 109)
                        .addComponent(btnAdmiModificarUsuario)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)
                        .addGap(17, 17, 17)
                        .addComponent(jLabel12))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pnlIngreseRutGarante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlIngresarDatosGarante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnModUsuario)
                    .addComponent(btnAdmiModificarUsuario))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        setSize(new java.awt.Dimension(733, 629));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnBuscarModusuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarModusuarioActionPerformed
        if(ValidarRutDAO.validarRut(this.txtRutBuscarModificaUsuario.getText().toUpperCase()))
           {
          javax.swing.JOptionPane.showMessageDialog(this, "Rut valido");
        if (txtRutBuscarModificaUsuario.getText().equals("")) {
            javax.swing.JOptionPane.showMessageDialog(null, "Por favor, ingrese el Rut del Usuario.");
        } else {
            usuarioDTO usuario = LOGIN.Administrador.BuscarUsuarioPorRut(txtRutBuscarModificaUsuario.getText());
            if (usuario.getRut_usua().equals("")) {
                javax.swing.JOptionPane.showMessageDialog(null, "Usuario no existe!.");
                txtRutBuscarModificaUsuario.setText("");
            } else {
                txtRutAdmiModUsuario.setText(usuario.getRut_usua());
                txtApellPatModiusuario.setText(usuario.getApell_paterno_usua());
                txtApellMatModUsuario.setText(usuario.getApell_materno_usua());
                txtNombreModUsuar.setText(usuario.getNombre_usua());
                Date aux = DTO.ConversionFechas.convertToDate(usuario.getFech_nac_usua());
                jcFecha_Nacimiento.setDate(aux);
                if (usuario.getSexo_usua().equalsIgnoreCase("Masculino")) {
                    rdMascAdmiModUsuario.setSelected(true);
                } else {
                    rdFemModUsuario.setSelected(true);
                }
                txtTelPartModUsuar.setText(String.valueOf(usuario.getTel_part_usua()));
                txtTrabModUsuario.setText(String.valueOf(usuario.getTel_trab_usua()));
                txtMovModUsuario.setText(String.valueOf(usuario.getTel_mov_usua()));
                txtFaxModUsuario.setText(String.valueOf(usuario.getFax_usua_int()));
                txtMailModUsuario.setText(usuario.getE_mail_usua());
                if (usuario.getEst_usuario_usua().equalsIgnoreCase("Activo")) {
                    chkEstadoUsuario.setSelected(true);
                } else {
                    chkEstadoUsuario.setSelected(false);
                }
                cmbPerfilUsuario.setSelectedIndex(LOGIN.Usuario.CargarPerfil(usuario.getPerfil().getNom_perfil()));
                txtUsuarioModUsuario.setText(usuario.getUsuario_usua());

                clave = usuario.getContrasena_usua();

                txtRutBuscarModificaUsuario.setEditable(false);
                btnBuscarModusuario.setEnabled(false);

            }
        }}else
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Rut invalido");
        }
    }//GEN-LAST:event_btnBuscarModusuarioActionPerformed

    private void btnModUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModUsuarioActionPerformed
        usuarioDTO usuario = new usuarioDTO();

        usuario.setRut_usua(this.txtRutAdmiModUsuario.getText().trim());
        usuario.setApell_paterno_usua(this.txtApellPatModiusuario.getText().trim());
        usuario.setApell_materno_usua(this.txtApellMatModUsuario.getText().trim());
        usuario.setNombre_usua(this.txtNombreModUsuar.getText());
        usuario.setFech_nac_usua(new SimpleDateFormat("dd/MM/yyyy").format(jcFecha_Nacimiento.getDate()));

        String sexo = "";
        if (this.rdMascAdmiModUsuario.isSelected()) {
            sexo = "Masculino";
        }
        if (this.rdFemModUsuario.isSelected()) {
            sexo = "Femenino";
        }
        usuario.setSexo_usua(sexo);

        if (!txtTelPartModUsuar.getText().equals("")) {
            usuario.setTel_part_usua(Integer.parseInt(this.txtTelPartModUsuar.getText()));
        }
        if (!txtTrabModUsuario.getText().equals("")) {
            usuario.setTel_trab_usua(Integer.parseInt(this.txtTrabModUsuario.getText().trim()));
        }
        if (!txtMovModUsuario.getText().equals("")) {
            usuario.setTel_mov_usua(Integer.parseInt(this.txtMovModUsuario.getText().trim()));
        }
        if (!txtFaxModUsuario.getText().equals("")) {
            usuario.setFax_usua_int(Integer.parseInt(this.txtFaxModUsuario.getText().trim()));
        }
        if (!txtMailModUsuario.getText().equals("")) {
            usuario.setE_mail_usua(this.txtMailModUsuario.getText().trim());
        }
        if (!txtPassModUsuar.getText().equals("") && txtPassModUsuar.getText().length() > 3) {
            usuario.setContrasena_usua(LOGIN.Encriptacion.getStringMessageDigest(txtPassModUsuar.getText(), LOGIN.Encriptacion.SHA512));
        } else {
            usuario.setContrasena_usua(clave);   
        }
        if(txtPassModUsuar.getText().length() > 0 && txtPassModUsuar.getText().length() < 4){
         javax.swing.JOptionPane.showMessageDialog(null, "Password no modificada, minimo 4 caracteres");
        }

        String aux = cmbPerfilUsuario.getSelectedItem().toString();
        switch (aux) {
            case "Ejecutivo":
                usuario.getPerfil().setCod_perfil(5);
                break;
            case "Supervisor":
                usuario.getPerfil().setCod_perfil(4);
                break;
            case "Jefe Sucursal":
                usuario.getPerfil().setCod_perfil(3);
                break;
            case "Gerente":
                usuario.getPerfil().setCod_perfil(2);
                break;
        }
        if (chkEstadoUsuario.isSelected()) {
            usuario.setEst_usuario_usua("Activo");
        } else {
            usuario.setEst_usuario_usua("Inactivo");
        }

        usuario.setUsuario_usua(txtUsuarioModUsuario.getText());

        int respuesta = javax.swing.JOptionPane.showConfirmDialog(null, "Esta Seguro de Modificar este Usuario?", "Modificar Usuario", JOptionPane.OK_CANCEL_OPTION);
        if (respuesta == 0) {
            LOGIN.Administrador.ModificarUsuario(usuario, user);
            javax.swing.JOptionPane.showMessageDialog(null, "Usuario Modificado");
            MenuAdministrador admi = new MenuAdministrador(user);
            admi.setVisible(true);
            ModuloAdmiModificarUsuario.this.dispose();
        } else {
        }

    }//GEN-LAST:event_btnModUsuarioActionPerformed

    private void btnAdmiModificarUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdmiModificarUsuarioActionPerformed
        MenuAdministrador admi = new MenuAdministrador(user);
        admi.setVisible(true);
        ModuloAdmiModificarUsuario.this.dispose();
    }//GEN-LAST:event_btnAdmiModificarUsuarioActionPerformed
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /*
//         * Set the Nimbus look and feel
//         */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /*
//         * If Nimbus (introduced in Java SE 6) is not available, stay with the
//         * default look and feel. For details see
//         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(ModuloAdmiModificarUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(ModuloAdmiModificarUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(ModuloAdmiModificarUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(ModuloAdmiModificarUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /*
//         * Create and display the form
//         */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new ModuloAdmiModificarUsuario().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdmiModificarUsuario;
    private javax.swing.JButton btnBuscarModusuario;
    private javax.swing.JButton btnModUsuario;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JCheckBox chkEstadoUsuario;
    private javax.swing.JComboBox cmbPerfilUsuario;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private com.toedter.calendar.JDateChooser jcFecha_Nacimiento;
    private javax.swing.JLabel lblRut;
    private javax.swing.JPanel pnlDatosPersonales;
    private javax.swing.JPanel pnlDireParticular;
    private javax.swing.JPanel pnlIngresarDatosGarante;
    private javax.swing.JPanel pnlIngreseRutGarante;
    private javax.swing.JPanel pnlNumContacto;
    private javax.swing.JRadioButton rdFemModUsuario;
    private javax.swing.JRadioButton rdMascAdmiModUsuario;
    private javax.swing.JTextField txtApellMatModUsuario;
    private javax.swing.JTextField txtApellPatModiusuario;
    private javax.swing.JTextField txtFaxModUsuario;
    private javax.swing.JTextField txtMailModUsuario;
    private javax.swing.JTextField txtMovModUsuario;
    private javax.swing.JTextField txtNombreModUsuar;
    private javax.swing.JTextField txtPassModUsuar;
    private javax.swing.JTextField txtRutAdmiModUsuario;
    private javax.swing.JTextField txtRutBuscarModificaUsuario;
    private javax.swing.JTextField txtTelPartModUsuar;
    private javax.swing.JTextField txtTrabModUsuario;
    private javax.swing.JTextField txtUsuarioModUsuario;
    // End of variables declaration//GEN-END:variables
}
